<?php
class CodeSpace_ServiceServer_Controller_Plugin_Gateway extends Zend_Controller_Plugin_Abstract
{

    public function __construct ()
    {}
    
    public function preDispatch (Zend_Controller_Request_Abstract $request)
    {
        // Creating Server
        $oauthServer = new CodeSpace_Oauth_Server_Gateway();
        
        // Configs
        $oauthServer->setConsumerKey('consumer-key');
        $oauthServer->setConsumerSecret('consumer-secret');
        $oauthServer->setAccessToken('access-token');
        $oauthServer->setAccessTokenSecret('access_token_secret');
        $oauthServer->setRequestTokenRequestUrl('http://morpheus.gateway.mkb.com:41000/oauth/requesttoken');
        $oauthServer->setAccessTokenRequestUrl('http://morpheus.gateway.mkb.com:41000/oauth/accesstoken');
        $oauthServer->setAuthorizationRequestUrl('http://morpheus.gateway.mkb.com:41000/oauth/authorization');
        $oauthServer->setSericeRequestUrl('idontknow');
        $oauthServer->setTransmissionRequestUrl('idontknow');
        
        // identifying the request and set it
        $oauthServer->setRequest();
        
        //Getting consumer and set the authentication method, 
        //in that case, database authentication
        $consumer = $oauthServer->getConsumer();
        
        $databaseAuthentication = $consumer->createDatabaseAuthentication();
        $databaseAuthentication->setDatabaseTableName('Model_DbTable_Consumers');
        $databaseAuthentication->setDatabaseTableColumnName('con_key');
        
        $oauthServer->handle();
    }
}
?>